﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WHMS.EntityClasses
{
	public partial class WithdrawRequestItemEntity
	{
		private string _itemNameCodeUnit;
		public int NewShelfId { get; set; }
		public string NewShelfCode { get; set; }
		public decimal QuantityToBeWithdrawn { get; set; }
	    public decimal Weight
	    {
	        get
	        {
	            return this.QuantityToBeWithdrawn * (this.Item != null ? this.Item.Weight : 0);
	        }
	    }

        public decimal IssueRequestWeight
        {
            get
            {
                return this.RequestedQuantity* (this.Item != null ? this.Item.Weight : 0);
            }
        }

        public decimal QuantityToBeRetrieved { get; set; }
		public decimal AvailableQantity { get; set; }

        public List<ShelfBalance> ShelvesBalances { get; set; }

		public decimal RemainderQuantity 
		{ 
			get 
			{
				return RequestedQuantity - WithdawedQuantity;
			} 
		}
		public string ItemNameCodeUnit
		{
			get
			{
				if(!string.IsNullOrEmpty(_itemNameCodeUnit))
				{
					return _itemNameCodeUnit;
				}
				else if (Item != null)
				{
					return Item.NameCodeUnit;
				}

				return string.Empty;
			}
			set 
			{
				_itemNameCodeUnit = value;
			}
		}
	}

	public partial class TransferRequestItemEntity
	{
		private string _itemNameCodeUnit;
		public int NewShelfId { get; set; }
		public string NewShelfCode { get; set; }
		public decimal QuantityToBeWithdrawn { get; set; }
		public decimal AvailableQantity { get; set; }
		public decimal RemainderQuantity
		{
			get
			{
				if (WithdawedQuantity.HasValue)
					return Quantity - WithdawedQuantity.Value;
				else
					return Quantity;
			}
		}

        public decimal Weight
        {
            get
            {
                return this.Quantity * (this.Item != null ? this.Item.Weight : 0);
            }
        }

		public string ItemNameCodeUnit
		{
			get
			{
				if (!string.IsNullOrEmpty(_itemNameCodeUnit))
				{
					return _itemNameCodeUnit;
				}
				else if (Item != null)
				{
					return Item.NameCodeUnit;
				}

				return string.Empty;
			}
			set
			{
				_itemNameCodeUnit = value;
			}
		}
		public decimal QuantityToBeAdded { get; set; }
	}
}